home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pasblk.zip / PASBLK.DOC < prev    next >
Text File  |  1990-04-28  |  7KB  |  120 lines

  1. PASBLK 1.5
  2.  
  3. PASBLK.PAS is a TP4/5 program that is designed to help visualize block
  4. structures in Pascal programs. It can be used on either a monochrome
  5. or a color monitor.  Blocks are displayed using seven different colors
  6. on a color monitor.  On a monochrome monitor four combinations of
  7. intensity and underlining are used to show the blocks.
  8.  
  9. PASBLK must be compiled with Turbo Pascal 4 or 5 (or modified for Turbo
  10. Pascal 3). Then it may be executed without any parameters on the
  11. command line to get a brief tutorial. When a Pascal program file name
  12. is given on the command line, PASBLK reads the file into memory; at this
  13. same time it searches for blocks and sets pointers to where colors will
  14. change when the lines are displayed. It also expands TABs if it finds
  15. any. When the entire file has been read onto the heap, then it is displayed
  16. with the blocks shown in their different colors and with comment fields
  17. shown in reverse video in the color of the block they fall into. The
  18. cursor up/down keys may be used to scroll the display forward or backward,
  19. and the PgUp, PgDn, Home, and End keys also work as usual. The Esc key
  20. terminates the program.
  21.  
  22. As part of its operation, PASBLK performs the following functions.
  23.  
  24. 1.) The video mode is checked before any file I/O is begun to
  25.     determine whether to use monochrome or color attributes.
  26.  
  27. 2.) The display color in effect when PASBLK first loads is saved and
  28.     restored at termination.
  29.  
  30. 3.) The block nesting depth is monitored, and if it does not return to
  31.     zero at the end-of-file, a warning is given; NOTE: not all block
  32.     nesting errors can be caught by the simple method of counting
  33.     opening and closing block keywords; there may be the same number
  34.     of openings and closings with block structures overlapping each
  35.     other, and the UNIT..END block may or may not have a BEGIN for
  36.     initialization code. For the last case, PASBLK assumes that if it
  37.     has seen a UNIT keyword and if the block nesting error is +1, then
  38.     it is because a BEGIN for initialization code was present, so it
  39.     is not an error, and no warning is given. It is beyond PASBLK's
  40.     scope to attempt to see whether the leftover nesting level could 
  41.     be explained by a BEGIN for initialization code.
  42.  
  43. 4.) A status-line area is given at the top of the screen; this shows the
  44.     file name (with any leading path clipped off), the current line range
  45.     (numbered according to the original file's lines, not counting wrapped
  46.     lines as more than one line), the total number of lines in the file,
  47.     and a reminder of which keys may be used to scroll or exit.
  48.  
  49. 5.) The file name is assumed to have an extension of ".PAS" if none is
  50.     given; if the desired file name has no extension, it must be given
  51.     with a period at the end.
  52.  
  53. 6.) A simple "state-machine" approach is used to keep comments and
  54.     literal strings from confusing the identification of block keywords;
  55.     the states are 0 (not in comment or string), 1 (in a string delimited
  56.     by single-quote marks), 3 (in a comment delimited by "(*" and "*)"),
  57.     and 4 (in a comment delimited by "{" and "}").
  58.  
  59. 7.) Lines longer than 80 characters are checked to see whether wrapping
  60.     will split a word; if so, blanks are inserted in front of the word that
  61.     would be split to keep from splitting it, provided a place to insert a
  62.     blank can be found in the last 40 columns. This is done so that keywords
  63.     won't be missed due to splitting; lines longer than 160 characters are
  64.     treated the same way; insertion of blanks may push characters out the end
  65.     of the 255-character string variable; if this happens, or if no place to
  66.     insert a blank can be found in the last 40 columns to split the line, a
  67.     warning is given, since a block nesting error may result, and in the case
  68.     where the line is shifted beyond the 255-character limit, some information
  69.     is lost. Extremely long lines are usually not a good idea, anyway.
  70.  
  71. PASBLK is limited to 2500 display lines (counting wrapped lines as more
  72. than one line) and 20 color changes per line; the limit on lines may be
  73. lower if less than 300K is available on the heap.
  74.  
  75. Seeing the blocks in different colors may help to find bugs in block nesting,
  76. and having the comments in reverse video helps to find accidentally unclosed
  77. comments that "eat" code and cause errors. If nothing else, the colored
  78. blocks are pretty to look at (just like the colored blocks most of us had as
  79. children!)
  80.  
  81. Besides unbalanced comment delimiters, unbalanced quote marks are also a
  82. common error that will cause PASBLK to warn of nesting errors. If this
  83. happens, look for the missing quote mark inside any block whose closing
  84. delimiter appears to have been ignored (for example, an END that is followed
  85. by text in the same color).
  86.  
  87. PASBLK is distributed free of charge subject to the following condition:
  88. it may not be sold or used in any way that requires payment for its use.
  89.  
  90.  
  91. ACKNOWLEDGMENT
  92.  
  93. The author would like to thank Ron Schuster for identifying and helping to
  94. fix two bugs in previous versions of PASBLK, and also for providing the
  95. motivation, information, and most of the coding to make PASBLK work on
  96. monochrome systems. Ron also contributed to this new version by identifying
  97. a manufacturer-dependent quirk in EGA behavior and by uncovering a deficiency
  98. in the expanded blank-insertion logic.
  99.  
  100.  
  101. CHANGES IN THIS VERSION
  102.  
  103. Version 1.4 would hang if it encountered an input line with a length greater
  104. than 80 columns and containing no blanks or blanks only at the beginning of
  105. the line; this has been fixed in version 1.5, which also has more generalized
  106. code for finding a place to split lines without splitting keywords.
  107.  
  108. This version scrolls faster when the PgUp or PgDn key is held down; the
  109. previous version would "coast", i.e., continue scrolling until it was caught
  110. up with buffered keystrokes. This version uses a WordStar-like approach,
  111. i.e., it does not complete painting the screen until it has caught up with
  112. any buffered keystrokes.
  113.  
  114. This version is better at restoring the screen attributes that existed prior
  115. to its execution; this affects only certain display systems with behavior that
  116. was not completely taken into account in the previous version.
  117.  
  118. This version handles OBJECT blocks. Note that TP5.5 is NOT required to
  119. compile PASBLK, however.
  120.